<?php
if($_POST['img']){
	require_once("php-sdk-6.1.11/qiniu/io.php");
	require_once("php-sdk-6.1.11/qiniu/rs.php");
	//获取图片
	$img = $_POST['img'];
	$img = str_replace('data:image/png;base64,', '', $img);
	$img = str_replace(' ', '+', $img);
	$data = base64_decode($img);
	$file = SAE_TMP_PATH .'/'.uniqid().'.png';
	file_put_contents($file, $data);
	//7牛
	$bucket = "qian";
	$key1 = uniqid().'.png';
	$accessKey = 'cavlSHqZsdo_8pLwsYcxP7J633WEHmrO2aQC8wqw';
	$secretKey = 'eYHlP2YtgBpaj8dMhatPNbfHs0rqiSUHwz3Co0o4';

	Qiniu_SetKeys($accessKey, $secretKey);
	$putPolicy = new Qiniu_RS_PutPolicy($bucket);
	$upToken = $putPolicy->Token(null);
	$putExtra = new Qiniu_PutExtra();
	$putExtra->Crc32 = 1;
	//存放文件
	list($ret, $err) = Qiniu_PutFile($upToken, $key1, $file, $putExtra);
	if ($err !== null) {
	    var_dump($err);
	} else {
		unlink($file);
	    echo json_encode($ret);
	}
}

?>